﻿// See https://aka.ms/new-console-template for more information
using QskjTotalData;

Console.WriteLine("Hello, World!");
#region 2.5当月报警总数数据汇总
ParameterizedThreadStart threadStart1 = new((obj) =>
{
    while (true)
    {
        if (DateTime.Now.Hour == 0 && DateTime.Now.Minute == 1)
        {
            Console.WriteLine(DateTime.Now + "当月报警总数数据汇总昨日数据开始");
            DateTime startTime = DateTime.Now.AddDays(-1).Date;//第一天
            DateTime endTime = DateTime.Now;
            DataAc.UpdateAlarmMonthData(startTime, endTime.AddDays(-1));//当月报警总数数据汇总
            Thread.Sleep(1000 * 60 * 30);
        }
        Thread.Sleep(1000);
    }
});
Thread thread1 = new Thread(threadStart1);
thread1.Start();
ParameterizedThreadStart threadStart111 = new((obj) =>
{
    //DataAc.UpdateAlarmMonthDataForFiliale(DateTime.Now.AddDays(-1).Date, DateTime.Now.AddDays(-1));//当月报警总数数据汇总
    while (true)
    {
        if (DateTime.Now.Hour == 2 && DateTime.Now.Minute == 1)
        {
            Console.WriteLine(DateTime.Now + "当月报警总数数据汇总昨日数据开始");
            DateTime startTime = DateTime.Now.AddDays(-1).Date;//第一天
            DateTime endTime = DateTime.Now;
            DataAc.UpdateAlarmMonthDataForFiliale(startTime, endTime.AddDays(-1));//当月报警总数数据汇总
            Thread.Sleep(1000 * 60 * 30);
        }
        Thread.Sleep(1000);
    }
});
Thread thread111 = new Thread(threadStart111);
thread111.Start();
#endregion
#region 2.6当日报警总数小时段数据汇总
ParameterizedThreadStart threadStart2 = new((obj) =>
{
    while (true)
    {
        if (DateTime.Now.Minute == 1)
        {
            Console.WriteLine(DateTime.Now + "当天报警总数数据汇总小时段数据开始");
            DateTime startTime = DateTime.Now.Date;//第一天
            DateTime endTime = Convert.ToDateTime($@"{startTime.Year}-{startTime.Month}-{startTime.Day} {DateTime.Now.Hour}:00:00");
            DataAc.UpdateAlarmDayData(startTime, endTime);//当月报警总数数据汇总
            Thread.Sleep(1000 * 60 * 30);
        }
        Thread.Sleep(1000);
    }
});
Thread thread2 = new Thread(threadStart2);
thread2.Start();
ParameterizedThreadStart threadStart21 = new((obj) =>
{
    while (true)
    {
        if (DateTime.Now.Minute == 1)
        {
            Console.WriteLine(DateTime.Now + "当天车队报警总数数据汇总小时段数据开始");
            DateTime startTime = DateTime.Now.Date;//第一天
            DateTime endTime = Convert.ToDateTime($@"{startTime.Year}-{startTime.Month}-{startTime.Day} {DateTime.Now.Hour}:00:00");
            DataAc.UpdateAlarmDayDataForFiliale(startTime, endTime);//当天车队报警总数数据汇总
            Thread.Sleep(1000 * 60 * 30);
        }
        Thread.Sleep(1000);
    }
});
Thread thread21 = new Thread(threadStart21);
thread21.Start();
#endregion
#region 2.9 近10天四公司车辆报警柱状图详情
ParameterizedThreadStart threadStart8 = new((obj) =>
{
    while (true)
    {
        if (DateTime.Now.Hour == 1 && DateTime.Now.Minute == 50)
        {
            Console.WriteLine(DateTime.Now + "2.9 近10天四公司车辆报警柱状图详情");
            DateTime startTime = DateTime.Now.AddDays(-1).Date;//第一天
            DateTime endTime = DateTime.Now.Date;
            DataAc.UpdateAlarmVehicleCompanyByTenToday(startTime, endTime);//公司当日报警总数
            Thread.Sleep(1000 * 60 * 30);
        }
        Thread.Sleep(1000);
    }
});
Thread thread8 = new Thread(threadStart8);
thread8.Start();
//2.91 近10天车队车辆四种类型报警柱状图详情
ParameterizedThreadStart threadStart81 = new((obj) =>
{
    //DataAc.UpdateAlarmVehicleCompanyByTenTodayForFili(DateTime.Now.AddDays(-1).Date, DateTime.Now.Date);//车队当日报警总数
    while (true)
    {
        if (DateTime.Now.Hour == 2 && DateTime.Now.Minute == 50)
        {
            Console.WriteLine(DateTime.Now + "2.91 近10天车队车辆报警柱状图详情");
            DateTime startTime = DateTime.Now.AddDays(-1).Date;//第一天
            DateTime endTime = DateTime.Now.Date;
            DataAc.UpdateAlarmVehicleCompanyByTenTodayForFili(startTime, endTime);//车队当日报警总数
            Thread.Sleep(1000 * 60 * 30);
        }
        Thread.Sleep(1000);
    }
});
Thread thread81 = new Thread(threadStart81);
thread81.Start();
#endregion
#region 2.10公司当日报警总数数据汇总
ParameterizedThreadStart threadStart3 = new((obj) =>
{
    while (true)
    {
        if (DateTime.Now.Hour == 1 && DateTime.Now.Minute == 1)
        {
            Console.WriteLine(DateTime.Now + "2.10公司当日报警总数数据汇总开始");
            DateTime startTime = DateTime.Now.AddDays(-1).Date;//第一天
            DateTime endTime = DateTime.Now.Date;
            DataAc.UpdateCompanyAlarmDayData(startTime, endTime);//公司当日报警总数
            Thread.Sleep(1000 * 60 * 30);
        }
        Thread.Sleep(1000);
    }
});
Thread thread3 = new Thread(threadStart3);
thread3.Start();
#endregion
#region 2.11 报警排名最高类型TOP10返回车辆报警排名最高类型TOP10
ParameterizedThreadStart threadStart4 = new((obj) =>
{
    while (true)
    {
        if (DateTime.Now.Hour == 1 && DateTime.Now.Minute == 10)
        {
            Console.WriteLine(DateTime.Now + "2.11 报警排名最高类型TOP10返回车辆报警排名最高类型TOP10");
            DateTime startTime = DateTime.Now.AddDays(-1).Date;//第一天
            DateTime endTime = DateTime.Now.Date;
            DataAc.UpdateAlarmTypeVehicleTopTen(startTime, endTime);//公司当日报警总数
            Thread.Sleep(1000 * 60 * 30);
        }
        Thread.Sleep(1000);
    }
});
Thread thread4 = new Thread(threadStart4);
thread4.Start();
ParameterizedThreadStart threadStart41 = new((obj) =>
{
    //DataAc.UpdateAlarmTypeVehicleTopTenForFiliale(DateTime.Now.AddDays(-1).Date, DateTime.Now.Date);//车队当日报警总数
    while (true)
    {
        if (DateTime.Now.Hour == 2 && DateTime.Now.Minute == 10)
        {
            Console.WriteLine(DateTime.Now + "2.111 车队报警排名最高类型TOP10返回车辆报警排名最高类型TOP10");
            DateTime startTime = DateTime.Now.AddDays(-1).Date;//第一天
            DateTime endTime = DateTime.Now.Date;
            DataAc.UpdateAlarmTypeVehicleTopTenForFiliale(startTime, endTime);//车队当日报警总数
            Thread.Sleep(1000 * 60 * 30);
        }
        Thread.Sleep(1000);
    }
});
Thread thread41 = new Thread(threadStart41);
thread41.Start();
#endregion
#region 2.12 报警排名最高车队TOP10返回车辆报警排名最高车队TOP10
ParameterizedThreadStart threadStart5 = new((obj) =>
{
    while (true)
    {
        if (DateTime.Now.Hour == 1 && DateTime.Now.Minute == 20)
        {
            Console.WriteLine(DateTime.Now + "2.12 报警排名最高车队TOP10返回车辆报警排名最高车队TOP10");
            DateTime startTime = DateTime.Now.AddDays(-1).Date;//第一天
            DateTime endTime = DateTime.Now.Date;
            DataAc.UpdateAlarmTypeVehicleFilialeTopTen(startTime, endTime);//公司当日报警总数
            Thread.Sleep(1000 * 60 * 30);
        }
        Thread.Sleep(1000);
    }
});
Thread thread5 = new Thread(threadStart5);
thread5.Start();
#endregion
#region 2.13 当日排名最高报警车辆TOP10返回车辆当日排名最高报警车辆TOP10
ParameterizedThreadStart threadStart6 = new((obj) =>
{
    while (true)
    {
        if (DateTime.Now.Hour == 1 && DateTime.Now.Minute == 30)
        {
            Console.WriteLine(DateTime.Now + "2.13 当日排名最高报警车辆TOP10返回车辆当日排名最高报警车辆TOP10");
            DateTime startTime = DateTime.Now.AddDays(-1).Date;//第一天
            DateTime endTime = DateTime.Now.Date;
            DataAc.UpdateAlarmTypeVehicleBcTopTen(startTime, endTime);//公司当日报警总数
            Thread.Sleep(1000 * 60 * 30);
        }
        Thread.Sleep(1000);
    }
});
Thread thread6 = new Thread(threadStart6);
thread6.Start();
#endregion
#region 2.14 当日排名最高报警驾驶员TOP200
ParameterizedThreadStart threadStart7 = new((obj) =>
{
    while (true)
    {
        if (DateTime.Now.Hour == 1 && DateTime.Now.Minute == 40)
        {
            Console.WriteLine(DateTime.Now + "2.14 当日排名最高报警驾驶员TOP200");
            DateTime startTime = DateTime.Now.AddDays(-1).Date;//第一天
            DateTime endTime = DateTime.Now.Date;
            DataAc.UpdateAlarmDrverData(startTime, endTime);//公司当日报警总数
            Thread.Sleep(1000 * 60 * 30);
        }
        Thread.Sleep(1000);
    }
});
Thread thread7 = new Thread(threadStart7);
thread7.Start();
ParameterizedThreadStart threadStart71 = new((obj) =>
{
    //DataAc.UpdateAlarmDrverDataCcp(DateTime.Now.AddDays(-1).Date, DateTime.Now.Date);//公司当日报警总数(类型为1抽烟，9超速，3疲劳)
    while (true)
    {
        if (DateTime.Now.Hour == 1 && DateTime.Now.Minute == 40)
        {
            Console.WriteLine(DateTime.Now + "2.141 当日排名最高报警驾驶员(类型为1抽烟，9超速，3疲劳)TOP200");
            DateTime startTime = DateTime.Now.AddDays(-1).Date;//第一天
            DateTime endTime = DateTime.Now.Date;
            DataAc.UpdateAlarmDrverDataCcp(startTime, endTime);//公司当日报警总数(类型为1抽烟，9超速，3疲劳)
            Thread.Sleep(1000 * 60 * 30);
        }
        Thread.Sleep(1000);
    }
});
Thread thread71 = new Thread(threadStart71);
thread71.Start();
#endregion
#region 6.2用户分析每隔一个小时统计整点用户在线数
ParameterizedThreadStart threadStart9 = new((obj) =>
{
    while (true)
    {
        if (DateTime.Now.Minute == 1)
        {
            Console.WriteLine(DateTime.Now + "当天报警总数数据汇总小时段数据开始");
            DateTime startTime = DateTime.Now.Date;//第一天
            DateTime endTime = Convert.ToDateTime($@"{startTime.Year}-{startTime.Month}-{startTime.Day} {DateTime.Now.Hour}:00:00");
            DataAc.UpdateUserDayData(startTime, endTime);//当日用户在线数据按小时统计
            Thread.Sleep(1000 * 60 * 30);
        }
        Thread.Sleep(1000);
    }
});
Thread thread9 = new Thread(threadStart9);
thread9.Start();
#endregion
#region 车队当日子类报警总数数据汇总
//qskjId子类3-疲劳，9-超速，1-抽烟，2-打电话
ParameterizedThreadStart threadStart10 = new((obj) =>
{
    //DataAc.UpdateFilialeAlarmDayData(DateTime.Now.AddDays(-1).Date);//车队当日子类报警总数数据汇总
    //DataAc.UpdateFilialeAlarmDayData(DateTime.Now.AddDays(-2).Date);//车队当日子类报警总数数据汇总
    //DataAc.UpdateFilialeAlarmDayData(DateTime.Now.AddDays(-3).Date);//车队当日子类报警总数数据汇总
    while (true)
    {
        if (DateTime.Now.Hour == 1 && DateTime.Now.Minute == 1)
        {
            Console.WriteLine(DateTime.Now + "车队当日子类报警总数数据汇总开始");
            DateTime startTime = DateTime.Now.AddDays(-1).Date;//前一天 
            DataAc.UpdateFilialeAlarmDayData(startTime);//车队当日子类报警总数数据汇总
            Thread.Sleep(1000 * 60 * 30);
        }
        Thread.Sleep(1000);
    }
});
Thread thread10 = new Thread(threadStart10);
thread10.Start();
#endregion
#region 当天大巴出租在线率报警检查数据
ParameterizedThreadStart threadStart11 = new((obj) =>
{
    while (true)
    {
        if (DateTime.Now.Minute % 5 == 0)
        {
            Console.WriteLine(DateTime.Now + "当天大巴出租在线率报警检查数据开始");
            DataAc.UpdateBusCarOnlineData();//当天大巴出租在线率报警检查数据开始
            DataAc.UpdateNetworkFilesData();//稽查数据上传证据视图库地址查询开始
            DataAc.UpdateVehicleOnlineData();//定时补充第一次上线车辆车队信息
            Thread.Sleep(1000 * 60);
        }
        Thread.Sleep(1000);
    }
});
Thread thread11 = new Thread(threadStart11);
thread11.Start();
#endregion
#region 违规复查报警数据统计数据生产
ParameterizedThreadStart threadStart12 = new((obj) =>
{
    //DataAc.SumAlarmAndFile();//违规复查报警数据统计数据生产
    while (true)
    {
        if (DateTime.Now.Hour == 1 && DateTime.Now.Minute == 50)
        {
            Console.WriteLine(DateTime.Now + "违规复查报警数据统计数据生产开始");
            DataAc.SumAlarmAndFile();//违规复查报警数据统计数据生产
            Thread.Sleep(1000 * 60);
        }
        Thread.Sleep(1000);
    }
});
Thread thread12 = new Thread(threadStart12);
thread12.Start();
#endregion
#region 车队在线数据统计数据生产
ParameterizedThreadStart threadStart13 = new((obj) =>
{
    //DataAc.SumFilialeOnline();//车队在线数据统计数据生产
    while (true)
    {
        if (DateTime.Now.Hour == 2 && DateTime.Now.Minute == 10)
        {
            Console.WriteLine(DateTime.Now + "车队在线数据统计数据生产");
            DataAc.SumFilialeOnline();//车队在线数据统计数据生产
            Thread.Sleep(1000 * 60);
        }
        Thread.Sleep(1000);
    }
});
Thread thread13 = new Thread(threadStart13);
thread13.Start();
#endregion
while (true)
{
    Thread.Sleep(1000 * 60);
}